package com.example.banksys;

import com.pixelduke.control.skin.FXSkins;
import javafx.fxml.FXMLLoader;
import javafx.scene.ImageCursor;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuItem;
import javafx.scene.image.Image;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;

import java.io.IOException;
import java.util.Objects;

public class ManagerMainpageController {
    public MenuItem HomePage;
    public AnchorPane leftPane;
    public AnchorPane rightPane;
    public Button employee;
    public Button trade;
    public Button business;
    public Menu home;
    public MenuItem quit;
    public AnchorPane mainpane;

    public void initialize() throws IOException {
        Pane t= FXMLLoader.load(Objects.requireNonNull(MainApplication.class.getResource("welcomePane.fxml")));
        t.layoutXProperty().set(90);
        t.layoutYProperty().set(85);
        rightPane.getChildren().add(t);
    }

    public void EmployeeSwitch() throws IOException {
        Pane t= FXMLLoader.load(Objects.requireNonNull(MainApplication.class.getResource("employeeManage.fxml")));
        if(!rightPane.getChildren().isEmpty())
            rightPane.getChildren().remove(1);
        rightPane.getChildren().add(t);
    }

    public void TradeSwitch() throws IOException {
        Pane t= FXMLLoader.load(Objects.requireNonNull(MainApplication.class.getResource("employeeTrade.fxml")));
        if(!rightPane.getChildren().isEmpty())
            rightPane.getChildren().remove(1);
        rightPane.getChildren().add(t);
    }

    public void BusinessSwitch() throws IOException {
        Pane t= FXMLLoader.load(Objects.requireNonNull(MainApplication.class.getResource("manageTradeManage.fxml")));
        if(!rightPane.getChildren().isEmpty())
            rightPane.getChildren().remove(1);
        rightPane.getChildren().add(t);
    }

    public void backToHome() throws IOException {
        Pane t= FXMLLoader.load(Objects.requireNonNull(MainApplication.class.getResource("welcomePane.fxml")));
        t.layoutXProperty().set(90);
        t.layoutYProperty().set(85);
        rightPane.getChildren().remove(1);
        rightPane.getChildren().add(t);
    }

    public void quit() throws IOException {
        mainpane.getScene().getWindow().hide();
        Stage stage=new Stage();
        FXMLLoader fxmlLoader = new FXMLLoader(MainApplication.class.getResource("Login.fxml"));
        Scene scene = new Scene(fxmlLoader.load());
        scene.getStylesheets().add(FXSkins.getStylesheetURL());
        stage.setTitle("银行系统");
        stage.setScene(scene);
        stage.setResizable(false);
        //stage.setWidth(1024);
        //stage.setHeight(700);
        stage.show();
    }



}
